package com.woniuxy.controller;

import com.woniuxy.bean.Menu;
import com.woniuxy.pojo.Permission;
import com.woniuxy.pojo.User;
import com.woniuxy.service.MenuService;
import org.apache.log4j.Logger;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
public class MenuController extends BaseController {
    private Logger logger= Logger.getLogger(this.getClass());
    @Autowired
    private MenuService menuService;
    @GetMapping(value = "/indexmenus.do")
    public List<Menu> loadIndexMenuList(){
        Subject subject=SecurityUtils.getSubject();
        Session session=subject.getSession();
        User user=(User)session.getAttribute("USER_SESSION");
        logger.info("**************"+user);
        List<Menu> menusList=menuService.getIndexLeftMenusByUid(user.getId());
        return menusList;
    }
}
